package net.obxlabs.tweetpad.behaviour;

import net.nexttext.*;
import net.nexttext.behaviour.*;
import net.nexttext.behaviour.control.*;
import net.nexttext.property.BooleanProperty;

/**
 * 
 * 
 * $Id:Throw.java 16 2007-11-27 10:50:46Z prisonerjohn $
 */
public class Throw extends OnDrag {
	
	public Throw(int buttonToCheck, Action trueAction, Action falseAction) {
    	super(buttonToCheck, trueAction, falseAction);
    }
	
	public boolean condition(TextObject to) {
		boolean dragging = super.condition(to);
		BooleanProperty draggingProp = (BooleanProperty)to.getProperty("Dragging");
        
		// set dragging status
		if (dragging) {
			if (draggingProp == null) {
        		to.init("Dragging", new BooleanProperty(true));
        	} else if (!draggingProp.get()) {
        		draggingProp.set(true);
        	}
        } else {
        	if (draggingProp == null) {
        		to.init("Dragging", new BooleanProperty(false));
        	} else if (!draggingProp.get()) {
        		draggingProp.set(false);
        	}
        }
		
		return dragging;
	}
}
